/********************************************************************
* Copyright (c) 2013,TGS,All rights reserved.
* fileName:	MapToPixel.h	
* created:	2013/04/23 8:36

* version:	1.6
* detail: 
*********************************************************************/

#pragma once

#include <TGS/MapControl2.0/config.h>
#include <vector>

class QPointF;
class QPoint;
class QPolygonF;
class QPolygon;
class QRect;

namespace TGS{
namespace GeoMath{
	class Point;
	class Polygon;
	class Envelope;
}
}

namespace TGS{
namespace MapControl{


/** \ingroup core
  * Perform transforms between map coordinates and device coordinates.
  *
  * This class can convert device coordinates to map coordinates and vice versa.
  */
class MAPCONTROL_EXPORT MapToPixel
{
public:
	typedef TGS::GeoMath::Point Point;
	typedef TGS::GeoMath::Envelope Envelope;
	typedef TGS::GeoMath::Polygon Polygon;
public:
    /* Constructor
    * @param mapUnitsPerPixel Map units per pixel
    * @param ymax Maximum y value of the map canvas
    * @param ymin Minimum y value of the map canvas
    * @param xmin Minimum x value of the map canvas
    */
    MapToPixel();
    //! destructor
    ~MapToPixel();
public:
    QPoint mapToScreen( const Point& mapPoint ) const;
	QPoint mapToScreen( const QPointF& mapPoint ) const;
	QPoint mapToScreen( double mapPointX, double mapPointY ) const;
	QPolygon mapToScreen(const QPolygonF& mapPolygon) const;
	QPolygon mapToScreen(const Polygon& mapPolygon) const;
	QRect mapToScreen(const Envelope& envelope) const;

    Point screenToMap(const QPoint& screenPoint ) const;
    Point screenToMap(int screenX, int screenY ) const;
	Polygon screenToMap(const QPolygon& screenPolygon) const;
	Envelope screenToMap(const QRect& rect) const;
			
    void setMapUnitsPerPixel( double mapUnitsPerPixel );

    //! Return current map units per pixel
    double mapUnitsPerPixel() const;

    void setParameters( double mapUnitsPerPixel, double mapMinX, double mapMinY, double screenMaxY );
    
private:
    double _MapUnitsPerPixel;
    double _screenMaxY;
    double _mapMinY;
    double _mapMinX;
};

}//MapControl
}//TGS